// 1.引入基础模块
import {createStore} from "vuex"


// 2.配置仓库 并获取仓库实例导出
export default createStore({
    // 2.1state
    // state: { }
    state() {
        return {
            age: 20,
            name: "李四"
        }
    },

    // 2.2getters  缓存  computed
    getters: {
        getName(state) {
            return state.name
        }
    },

    // 2.3mutations 定义修改state的规则  不能执行异步
    mutations: {
        changeName(state, newV) {
            state.name = newV
        }
    },

    // 2.4actions 执行异步 控制mutations操作state
    actions: {
        changeNameA(content, newV) {
            content.commit('changeName', newV)
        }
    },

    // 2.5modules
    modules: {}


})